<?php
class IndexAction extends Action {
	/*获取内容列表*/
	public function checkList($countWhere,$dataWhere,$order){
		import("@.ORG.Page");
		$count = M('News')->where($countWhere)->count('id');
		$p     = new Page ($count,C('listnews'));
		$list = M()->Table(array(C('DB_PREFIX').'news'=>'news',C('DB_PREFIX').'user'=>'user'))->where($dataWhere)->order($order)->limit($p->firstRow.','.$p->listRows)->select();
		$p->setConfig('theme','%totalRow% %header% %first% %prePage% %linkPage% %nextPage% %end%');
		$page = $p->show();
		foreach($list as $key=>$value){
			$list[$key]['title'] = $value['title'];
			$list[$key]['face'] = C('YICMS_PUBLIC').'/face/f_'.$value['face'];
			$list[$key]['mpic'] = C('URL').'/Public/news/m_'.$value['pic'];
			$list[$key]['spic'] = C('URL').'/Public/news/s_'.$value['pic'];
			if(!empty($value['tag'])) $list[$key]['tag'] = explode(' ',$value['tag']);
			$list[$key]['content'] = preg_replace('/yi_show\((.*?),event\)/',"yi_show(\\1,event,".$value['id'].")",$value['content']);
		}
		//dump($list);
		if(!empty($list)) $this->assign('count',$count);
		else $this->assign('count',0);
		$this->assign('list',$list);
		$this->assign('page',$page);
	}
	/*获取标签列表*/
	public function tagList(){
	
		$tagList = M('Tag')->field('distinct(name),url')->order('taxis ASC,id DESC')->limit(C('tagnum'))->select();
		foreach($tagList as $key=>$value){
			if(empty($value['url'])){
				$tagList[$key]['url'] = '<a href="/tag/'.$value['name'].'">'.$value['name'].'</a>';
			}else{
				$tagList[$key]['url'] = '<a href="'.$value['url'].'" target="_blank">'.$value['name'].'</a>';
			}
			
		}
		
		$this->assign('tagList',$tagList);
	}
	/*获取公共参数*/
	public function about(){
		$this->assign('HOME_PUBLIC',C('HOME_PUBLIC'));
		$this->assign('YICMS_PUBLIC',C('YICMS_PUBLIC'));
		$this->assign('about',M('About')->find());		
		$nav = M('nav')->where('state = 0 AND id != 1')->field('name,sname')->limit('3')->order('taxis asc')->select();
		$this->assign('nav',$nav);		
	}
	/*网站首页*/
	public function index(){
		//网站配置
		$config = M('Config')->find();
		if($_GET['p']){
			$config['title'] = $config['stitle'].'-第'.(int)$_GET['p'].'页-'.$config['title'];
		}else{
			$config['title'] = $config['stitle'].'-'.$config['title'];
		}
		$this->assign('config',$config);
		
		$this->about();
		$time = $_SERVER['REQUEST_TIME'] - 1072*60*60;
		$countWhere = 'state=1 AND time>'.$time;
		$dataWhere  = 'news.time >'.$time.' AND news.state = 1 AND news.uid = user.uid';
		$order      = 'news.time DESC';
		$this->checkList($countWhere,$dataWhere,$order);
		$this->tagList();
		
		$tui = M('news')->where('pic != "" AND state = 1')->field('id,pic,time,uid')->limit(16)->order('click desc,time desc')->select();
		foreach($tui as $key=>$val){
			$uid = $tui["$key"]['uid'];
			$tui["$key"]['user'] = M('user')->field('uname')->where("uid = $uid")->find();
		}
		$this->assign('tui',$tui);
		$this->display();
	}
	/*24小时内*/
	public function day(){
		//网站配置
		$config = M('Config')->find();
		if($_GET['p']){
			$config['title'] = '24小时内 - '.'第'.(int)$_GET['p'].'页 - '.$config['stitle'];
		}else{
			$config['title'] = '24小时内 - '.$config['stitle'];
		}
		$this->assign('config',$config);		
		$this->about();
		$time = $_SERVER['REQUEST_TIME'] - 24*60*60;
		$countWhere = 'state=1 AND time>'.$time;
		$dataWhere  = 'news.time >'.$time.' AND news.state = 1 AND news.uid = user.uid';
		$order      = 'news.yes DESC';
		$this->checkList($countWhere,$dataWhere,$order);
		$this->tagList();
		$this->display();
	}
	/*1周内*/
	public function week(){
		//网站配置
		$config = M('Config')->find();
		if($_GET['p']){
			$config['title'] = '最新一周-'.'第'.(int)$_GET['p'].'页-'.$config['stitle'];
		}else{
			$config['title'] = '最新一周-'.$config['stitle'];
		}
		$this->assign('config',$config);		
		$this->about();
		$time = $_SERVER['REQUEST_TIME'] - 7*24*60*60;
		$countWhere = 'state=1 AND time>'.$time;
		$dataWhere  = 'news.time >'.$time.' AND news.state = 1 AND news.uid = user.uid';
		$order      = 'news.yes DESC';
		$this->checkList($countWhere,$dataWhere,$order);
		$this->tagList();
		$this->display();
	}
	/*1个月*/
	public function month(){
		//网站配置
		$config = M('Config')->find();
		if($_GET['p']){
			$config['title'] = '最新一个月-'.'第'.(int)$_GET['p'].'页 - '.$config['stitle'];
		}else{
			$config['title'] = '最新一个月-'.$config['stitle'];
		}
		$this->assign('config',$config);
		
		$this->about();
		$time = $_SERVER['REQUEST_TIME'] - 7*24*60*60;
		$countWhere = 'state=1 AND time>'.$time;
		$dataWhere  = 'news.time >'.$time.' AND news.state = 1 AND news.uid = user.uid';
		$order      = 'news.yes DESC';
		$this->checkList($countWhere,$dataWhere,$order);
		$this->tagList();
		$this->display();
	}
	/*best*/
	public function best(){
		//网站配置
		$config = M('Config')->find();
		if($_GET['p']){
			$config['title'] = '排行榜-'.'第'.(int)$_GET['p'].'页-'.$config['stitle'];
		}else{
			$config['title'] = '排行榜-'.$config['stitle'];
		}
		$this->assign('config',$config);
		
		$this->about();
		$countWhere = 'state=1';
		$dataWhere  = 'news.state = 1 AND news.uid = user.uid';
		$order      = 'news.yes DESC,news.time DESC';
		$this->checkList($countWhere,$dataWhere,$order);
		$this->tagList();
		$this->display();
	}
	/*糗事内页*/
	public function article(){
		$this->about();
		$id = explode('#',$_GET['_URL_'][2]);
		$id = (int)$id[0];
		
		$res = M('News')->where("id = $id")->find();
		if(!$res){
			$this->error('没有找到这个帖子');
		}
		M('News')->where("id = $id")->setInc('click',1);
		$news = M()->Table(array(C('DB_PREFIX').'news'=>'news',C('DB_PREFIX').'user'=>'user'))->where("news.id = $id AND news.state = 1 AND news.uid = user.uid")->find();
		
		$news['content'] = preg_replace('/yicms\((.*?),event\)/',"yicms(\\1,event,".$news['id'].")",$news['content']);
		
		$news['mpic'] = C('URL').'/Public/news/m_'.$news['pic'];
		$news['face'] = C('URL').'/Public/face/f_'.$news['face'];
		if(!empty($news['tag'])){
			$tags = $news['tag'];
			$news['tag'] = explode(' ',$news['tag']);
		}
		$this->assign('news',$news);
		$reply = M()->Table(array(C('DB_PREFIX').'reply'=>'reply',C('DB_PREFIX').'user'=>'user'))->where("reply.pid = $id AND reply.state = 1 AND reply.arid = user.uid")->order('reply.artime ASC')->select();
		$this->assign('reply',$reply);
		$config = M('Config')->find();
		if($news['title']){
			$config['title'] = $news['title'].'-'.$config['stitle'];
		}else{
			$config['title'] = '糗事#'.$news['id'].'-'.$config['stitle'];
		}	
		if(!empty($tags)){
			$config['keywords'] = $tags;
		}else{
			$config['keywords'] = $news['title'].'-'.$config['keywords'];
		}
		if(empty($news['video']) || empty($news['pic'])) $config['description'] = msubstr(strip_tags(htmlspecialchars($news['content'])),0,120,'utf-8',false);
		else $config['description'] = $news['title'].'-'.$config['description'];
		$this->assign('config',$config);
		$this->tagList();
		$this->display();
	}
	/*TAG搜索页*/
	public function tag(){
		$this->about();
		if($_GET['name']) $name = $_GET['name'];
		elseif($_GET['_URL_'][2]) $name = $_GET['_URL_'][2];
		else $this->error('不准进!');
		//if($name !== iconv('UTF-8','UTF-8',iconv('UTF-8','UTF-8',$name))) $name =  iconv('GBK','UTF-8',$name);
		//网站配置
		$config = M('Config')->find();
		if($_GET['p']){
			$config['title'] = $name.'-标签聚合-第'.(int)$_GET['p'].'页-'.$config['stitle'];
		}else{
			$config['title'] = $name.'-标签聚合-'.$config['stitle'];
		}
		$config['keywords'] = $name.'-'.$config['keywords'];
		$this->assign('config',$config);
		
		$this->assign('name',$name);
		if($_GET['name']){
			$countWhere = "state=1 AND content like '%$name%'";
			$dataWhere  = "news.state = 1 AND news.uid = user.uid AND news.content like '%$name%'";
		}elseif($_GET['_URL_'][2]){
			$countWhere = "state=1 AND tag like '%$name%'";
			$dataWhere  = "news.state = 1 AND news.uid = user.uid AND news.tag like '%$name%'";
		}	
		$order      = 'news.time DESC';
		$this->checkList($countWhere,$dataWhere,$order);
		$this->tagList();
		$this->display();
	}
	/*标签聚合*/
	public function tagcloud(){
		$this->about();
		import("@.ORG.Page");
		$count = M('News')->where("state = 1 AND tag <> ''")->count('id');
		$p     = new Page ($count,C('listnews'));
		$news  = M('News')->field('tag')->where("state = 1 AND tag <> ''")->order('time DESC')->limit($p->firstRow.','.$p->listRows)->select();
		$p->setConfig('theme','%first% %prePage% %linkPage% %nextPage% %end%');
		foreach($news as $value){
			$tag    = explode(' ',$value['tag']);
			$list[] = $tag[0];
			if(!empty($tag[1])) $list[] = $tag[1];
			if(!empty($tag[2])) $list[] = $tag[2];
			
		}
		$page = $p->show();
		$list = array_unique($list);
		$this->assign('list',$list);
		$this->assign('page',$page);
		//网站配置
		$config = M('Config')->find();
		if($_GET['p']){
			$config['title'] = '标签聚合-第'.(int)$_GET['p'].'页-'.$config['stitle'];
		}else{
			$config['title'] = '标签聚合-'.$config['stitle'];
		}
		$config['keywords'] = $name.'-'.$config['keywords'];
		$this->assign('config',$config);
		$this->tagList();
		$this->display();
	}
	/*穿越*/
	public function history(){
		$this->about();
		$time = (int)$_GET['_URL_'][2];
		if(empty($time)) $time = date('Y').date('m').date('d');
		//网站配置
		$config = M('Config')->find();
		if($_GET['p']){
			$config['title'] = $time.'-穿越-第'.(int)$_GET['p'].'页-'.$config['stitle'];
		}else{
			$config['title'] = $time.'-穿越-'.$config['stitle'];
		}
		$this->assign('config',$config);
		
		$year = substr($time,0,4);
		$month = substr($time,4,2);
		$day = substr($time,6,2);
		$startTime = mktime(0,0,0,$month,$day,$year);
		$stopTime  = mktime(23,59,59,$month,$day,$year);
		$countWhere = "state=1 AND time>'$startTime' AND time<'$stopTime'";
		$dataWhere  = "news.state = 1 AND news.uid = user.uid AND news.time>'$startTime' AND news.time<'$stopTime'";
		$order      = 'news.time DESC';
		$this->checkList($countWhere,$dataWhere,$order);
		$this->assign('year',$year);
		$this->assign('month',$month);
		$this->assign('day',$day);
		/*输出日历*/
		import("@.ORG.Calendar");
		$cal = new Calendar($time);
		$getMonth = $cal->getMonth();
		$this->assign('getMonth',$getMonth);
		$getDay = $cal->getDay($startTime);
		$this->assign('getDay',$getDay);
		$this->display();
	}
	/*发表贴子*/
	public function add(){
		$this->about();
		//网站配置
		$config = M('Config')->find();
		if($_GET['p']){
			$config['title'] = '发贴-第'.(int)$_GET['p'].'页-'.$config['stitle'];
		}else{
			$config['title'] = '发贴-'.$config['stitle'];
		}
		$this->assign('config',$config);
		
		$this->tagList();
		$this->display();
	}
	/*审贴*/
	public function ticket(){
		$this->about();
		//网站配置
		$config = M('Config')->find();
		if($_GET['p']){
			$config['title'] = '审贴-第'.(int)$_GET['p'].'页-'.$config['stitle'];
		}else{
			$config['title'] = '审贴-'.$config['stitle'];
		}
		$this->assign('config',$config);
		$this->assign('ticketmsg',C('ticketmsg'));
		$this->tagList();
		$this->display();
	}
	/*列表页*/
	public function _empty($name){
		$nav_nlist = M('Nav')->field('id,name,title,keywords,description')->where("sname='$name'")->find();
		if(empty($nav_nlist)) $this->error('不存在此页面!');
		$this->about();
		//网站配置
		$config = M('Config')->find();
		if($nav_nlist['title']){
			if($_GET['p']){
				$config['title'] = $nav_nlist['title'].'-第'.(int)$_GET['p'].'页';
			}else{
				$config['title'] = $nav_nlist['title'];
			}
		}else{
			if($_GET['p']){
				$config['title'] = $nav_nlist['name'].'-第'.(int)$_GET['p'].'页-'.$config['stitle'];
			}else{
				$config['title'] = $nav_nlist['name'].'-'.$config['stitle'];
			}
		}
		if($nav_nlist['keywords']) $config['keywords'] = $nav_nlist['keywords'];
		if($nav_nlist['description']) $config['description'] = $nav_nlist['description'];
		$this->assign('config',$config);
		$countWhere = 'state=1 AND pid='.$nav_nlist['id'];
		$dataWhere  = 'news.pid ='.$nav_nlist['id'].' AND news.state = 1 AND news.uid = user.uid';
		$order      = 'news.time DESC';
		$this->checkList($countWhere,$dataWhere,$order);
		$this->tagList();
		$nav_nlist[$name] = true;
		$this->assign('nav_nlist',$nav_nlist);
		if($name=='qiutu'){
			$p = empty($_GET['p']) ? '1' : intval($_GET['p']);
			$url = '/qiutu?&p='.($p+1);
			$this->assign('url',$url);
			$this->assign('p',$p);
			$this->display('pic');
		}else{
			$this->display('nlist');
		}
	}
	/*用户中心界面*/
	public function user(){
		$this->about();
		$this->assign('USER_PUBLIC',C('URL').'/YiCms/Tpl/User/'.C('DEFAULT_THEME').'/Public');
		$uid = $_GET['_URL_'][2];
		$tmp = $_GET['_URL_'][3];
		if(empty($uid)) $uid = $_SESSION['uid'];
		if(empty($uid)) $this->error('要么登录,要么只能访问别人的!');
		$profile = M('User')->where("uid = $uid")->find();
		if(empty($profile)) $this->error('该用户不存在!');
		if($profile['state'] == '0') $this->error('该用户已被禁止登录,');
		$profile['face'] = C('YICMS_PUBLIC').'/face/f_'.$profile['face'];
		$this->assign('profile',$profile);
		//网站配置
		$config = M('Config')->find();
		$config['title'] = $profile['uname'].'-会员中心-'.$config['stitle'];
		$this->assign('config',$config);
		if(empty($tmp) || $tmp=='index'){
			$news = M('News')->where("uid = $uid")->order('time DESC')->limit(10)->select();
			$this->assign('news',$news);
			$this->display('YiCms/Tpl/User/Default/Index_index.html');
		}elseif($tmp=='articles'){
			import("@.ORG.Page");
			$count = M('News')->where("uid = $uid")->count('id');	
			$p     = new Page($count, 10);			
			$articles = M('News')->where("uid = $uid")->order('time DESC')->limit($p->firstRow.','.$p->listRows)->select();
			$this->assign('articles',$articles);
			$page = $p->show();
			$this->assign("page", $page );
			$this->display('YiCms/Tpl/User/Default/Index_articles.html');
		}elseif($tmp=='comments'){
			import("@.ORG.Page");
			$count = M('Reply')->where("arid = $uid")->count('id');	
			$p     = new Page($count, 10);			
			$comments = M('Reply')->where("arid = $uid")->order('artime DESC')->limit($p->firstRow.','.$p->listRows)->select();
			$this->assign('comments',$comments);
			$page = $p->show();
			$this->assign("page", $page );
			$this->display('YiCms/Tpl/User/Default/Index_comments.html');
		}
		
		
		
	}
	/*Ajax检测用户发布内容*/
	public function checkForm(){
		if(md5($_POST['verify']) != $_SESSION['verify']) exit('-1');
		$content = trim($_POST['content']);
		$video = trim($_POST['video']);
		if(empty($content) && empty($_POST['pic']) && empty($video)) exit('-3');
		if(count(explode(' ',trim($_POST['tag'])))>3) exit('-4');
		if(!empty($_POST['pic']) && !empty($video)) exit('-5');
		if(!empty($video) && !in_array(array_pop(explode('.',$video)),array('swf','flv')) && !get_headers($video)) exit('-6');
		if(!empty($_POST['email']) && !preg_match("/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/i",$_POST['email'])) exit('-7');
	}
	
	public function checkAdd(){
		header('Cache-Control: no-cache');
	if(C('opencws')){
		/*导入中文分词类，分词后加上链接*/
		import("@.ORG.initcws");
		$cws = new initcws();

		$taglist = M('Tag')->field('name,url')->order('taxis ASC,id DESC')->limit(20)->select();
		
		$_POST['content'] = str_replace('#','',zen_key_replace($cws->cws($_POST['content']),$taglist));
	}else{
		$_POST['content'] =  trim($_POST['content']);
	}
	
	
	
	
		//获取用户UID
		if(empty($_SESSION['uid']) || $_POST['anonymous']) $_POST['uid'] = '1';
		else $_POST['uid'] = $_SESSION['uid'];
		//获取用户名
		if(empty($_SESSION['uname']) || $_POST['anonymous']) $_POST['author'] = '匿名发布';
		else $_POST['author'] = $_SESSION['uname'];
		//时间
		$_POST['time'] = $_SERVER['REQUEST_TIME'];
		$_POST['tag'] =  htmlspecialchars(trim($_POST['tag']),ENT_QUOTES,'utf-8');
		if(!empty($_SESSION['uid'])){
			$uid = $_SESSION['uid'];
			$user = M('User')->field('email')->where("uid = $uid")->find();
			$_POST['email'] = $user['email'];
		}
		

		if($_FILES['pic']['error'] != '4'){
			import("@.ORG.UploadFile");
			$upload = new UploadFile();
			$upload->maxSize =20971520;
			$upload->allowExts = explode(',','jpg,gif,png,jpeg');
			$upload->savePath ='Public/news/';
			if($_FILES['pic']['type']!='image/gif'){
				$upload->thumb=true;
				$upload->imageClassPath = '@.ORG.Image';
				$upload->thumbPrefix = 'm_,s_';
				$upload->thumbMaxWidth  = C('newsmwidth').','.C('newsswidth');
				$upload->thumbMaxHeight = C('newsmheight').','.C('newsmheight');
				$upload->thumbRemoveOrigin = true;
			}
			$upload->saveRule = uniqid;
			if(!$upload->upload()){			$this->error($upload->getErrorMsg());
			}else{
				$uploadList = $upload->getUploadFileInfo();
				$_POST['pic'] = $uploadList[0]['savename'];
				if($_FILES['pic']['type']!='image/gif'){
					import("@.ORG.Image");
					Image::watermark($uploadList[0]['savepath'].'m_'.$uploadList[0]['savename']);
					Image::watermark($uploadList[0]['savepath'].'s_'.$uploadList[0]['savename']);
				}else{
					copy($uploadList[0]['savepath'].$uploadList[0]['savename'],$uploadList[0]['savepath'].'m_'.$uploadList[0]['savename']);
					copy($uploadList[0]['savepath'].$uploadList[0]['savename'],$uploadList[0]['savepath'].'s_'.$uploadList[0]['savename']);
					unlink($uploadList[0]['savepath'].$uploadList[0]['savename']);
				}	
			}
			$_POST['pid'] = 3;
		}elseif(!empty($_POST['video'])){
			$_POST['video'] =  htmlspecialchars(trim($_POST['video']));
			$_POST['pid'] = 4;
		}else{
			$_POST['pid'] = 2;
		}
		if(empty($_POST['title'])){

					$_POST['title'] = msubstr(strip_tags($_POST['content']),0,20,'utf-8',false);

		}else{
			$_POST['title']  = htmlspecialchars($_POST['title']);
		}
		$vo = M('News')->add($_POST);
		if(!$vo) $this->error('发布失败!您可以重新试试.');
		if(empty($_SESSION['uid']) || !empty($_POST['anonymous'])) $uid='1';
		else $uid = $_SESSION['uid'];
		M('User')->where("uid = $uid")->setInc('articles');
		$this->assign('vo',$vo);
		$this->about();
		//网站配置
		$config = M('Config')->find();
		$config['title'] = '发贴成功-'.$config['stitle'];
		$this->assign('config',$config);
		$this->tagList();
		if(!empty($_SESSION['tweibo'])){
			require_once './tweibo/Config.php';
			require_once './tweibo/Tencent.php';
			OAuth::init($client_id, $client_secret);
			Tencent::$debug = $debug;
			if ($_SESSION['t_access_token'] || ($_SESSION['t_openid'] && $_SESSION['t_openkey'])) {//用户已授权
				if(!empty($_POST['pic'])){
					$params = array(
						'content' => msubstr($_POST['content'],0,120).C('URL'),
						'pic_url' => C('YICMS_PUBLIC').'/news/m_'.$_POST['pic']
					);
					$r = Tencent::api('t/add_pic_url', $params, 'POST');
				}else{
					$params = array(
						'content' => msubstr($_POST['content'],0,120).C('URL'),
					);
					$r = Tencent::api('t/add', $params, 'POST');
				}
			}
		}
		unset($_POST);
		$this->display();
	}
	public function suggest(){
		$list['content'] = htmlspecialchars(trim($_POST['content']));
		if(empty($list['content'])){
			$this->error('请填写建议内容^_^');
		}else{
			$list['time'] = $_SERVER['REQUEST_TIME'];
			$list['ip'] = ip2long($_SERVER['REMOTE_ADDR']);
			M('Suggest')->add($list);
			$this->success('感谢您的建议!我们将及时改进!');
		}
	}
	public function report(){
		$id = (int)$_POST['comment_id'];
		$data = M('Reply');
		$data->where("id = $id")->setInc('report');
		$reply = $data->field('pid,arid,report')->where("id = $id")->find();
		$maxreport = C('maxreport');
		if($reply['report']>=$maxreport){
			$data->where("id = $id")->delete();
			$pid  = $reply['pid'];
			$arid = $reply['arid'];
			M('News')->where("id = $pid")->setDec('reply');
			M('User')->where("arid = $arid")->setDec('comments');
		}
	}
	public function verify(){
		import("@.ORG.Image");
		Image::buildImageVerify(4,1,'jpeg',53,25); 
	}
	
	public function boxAjax(){	
	if(empty($_POST['str'])){
		$str_one = explode(',',$_POST['str_one']);
		
		$tag = $str_one['0'];
		$sid = $str_one['1'];		
			$where = "`title` like '%$tag%' AND `state` = 1 AND `video` = '' AND id < $sid OR `tag` like '%$tag%' AND `state` = 1 AND `video` = '' AND id != $sid ";
		}else{		
			$str = explode(',',$_POST['str']);
			$aid = (int)$str['0'];
			$tag = htmlspecialchars($str[1],ENT_QUOTES,'utf-8');
			$where = "`title` like '%$tag%' AND `id` < $aid AND `state` = 1 AND `video` = '' OR `tag` like '%$tag%' AND `id` < $aid AND `state` = 1 AND `video` = ''";
		}

		$list = M('news')->field('id,title,content,pic')->order('time desc')->where($where)->find();

		if(!empty($list)){
					
			$str = '<a href="/article/'.$list['id'].'">'.strip_tags(mb_substr($list['content'],0,2400,'utf-8')).'</a><br /><br />';
			if($list['pic']){
				$str.= '<a href="/article/'.$list['id'].'"><img style="width:250px;height:180px" src="/Public/news/s_'.$list['pic'].'" /></a><br /><br />';
			}
			echo $str;
			echo  '<a style="font-size:12px;float:right" href="javascript:next_page('.$list['id'].','."'".$tag."'".');">下一页</a>';
		}else{
			exit('<center>没有了！</center>');
		}
	
	}
}
?>